/*
 * Copyright (c) 2014, S.F. Express Inc. All rights reserved.
 */
package org.jasig.cas.client.ext;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.jasig.cas.client.util.AbstractCasFilter;
import org.jasig.cas.client.validation.Assertion;

/**
 * 描述：CASClient抽象类
 * 
 * <pre>
 * HISTORY
 * ****************************************************************************
 *  ID   DATE            PERSON          REASON
 *  1    2015年12月15日     014767          Create
 * ****************************************************************************
 * </pre>
 * 
 * @author 014767
 * @since 1.0
 */
public abstract class AbstractCASClient implements ICASClient {

    public boolean useSession() {
        return true;
    }

    public boolean isLogin(HttpServletRequest request, HttpServletResponse response) {
        if (useSession()) {
            HttpSession session = request.getSession(false);
            if (session != null) {
                Assertion assertion = (Assertion) session.getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
                if (assertion != null) {
                    return true;
                }
            }
        }
        return false;
    }

    public boolean onFailedValidation(final HttpServletRequest request, final HttpServletResponse response) {
        return false;
    }

    public Node getNode() {
        return null;
    }
}
